//
//  UIWindow+YFHelper.m
//  YunFu
//
//  Created by Bager on 2018/9/12.
//  Copyright © 2018年 yunfu. All rights reserved.
//

#import "UIWindow+YFHelper.h"

@implementation UIWindow (YFHelper)


- (UIViewController*)sh_topMostController
{
    //  getting rootViewController
    UIViewController *topController = [self rootViewController];
    
    //  Getting topMost ViewController
    while ([topController presentedViewController]) topController = [topController presentedViewController];
    
    //  Returning topMost ViewController
    return topController;
}

- (UIViewController*)sh_currentViewController
{
    UIViewController *currentViewController = [self sh_topMostController];
    
    while ([currentViewController isKindOfClass:[UINavigationController class]] && [(UINavigationController*)currentViewController topViewController])
        currentViewController = [(UINavigationController*)currentViewController topViewController];
    
    return currentViewController;
}

@end
